//-----------------------------------------------------------------------
// <copyright file="PermissionService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class PermissionService
    {
        #region Permission

        public static void CreatePermission(Permission permission)
        {            
            try
            {
                PermissionDAO permissionDAO = new PermissionDAO();
                permissionDAO.CreatePermission(permission);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreatePermissionException, ex);
            }
        }        

        public static void UpdatePermission(Permission permission)
        {            
            try
            {
                PermissionDAO permissionDAO = new PermissionDAO();
                permissionDAO.UpdatePermission(permission);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdatePermissionException, ex);
            }
        }        

        public static void DeletePermission(int permissionId)
        {            
            try
            {
                PermissionDAO permissionDAO = new PermissionDAO();
                permissionDAO.DeletePermission(permissionId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeletePermissionException, ex);
            }
        }
        
        public static Permission GetPermission(int permissionId)
        {            
            try
            {
                PermissionDAO permissionDAO = new PermissionDAO();
                return permissionDAO.GetPermission(permissionId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetPermissionException, ex);
            }
        }                

        public static PermissionCollection GetPermissionList(PermissionColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                PermissionDAO permissionDAO = new PermissionDAO();
                return permissionDAO.GetPermissionList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetPermissionListException, ex);
            }
        }        

        public static PermissionCollection GetPermissionList(PermissionColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                PermissionDAO permissionDAO = new PermissionDAO();
                return permissionDAO.GetPermissionList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetPermissionListException, ex);
            }
        }        

	    public static PermissionCollection GetPermissionListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                PermissionDAO permissionDAO = new PermissionDAO();
                return permissionDAO.GetPermissionListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetPermissionListException, ex);
            }
        }        

        public static PermissionCollection GetPermissionListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                PermissionDAO permissionDAO = new PermissionDAO();
                return permissionDAO.GetPermissionListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetPermissionListException, ex);
            }
        }        

        #endregion
    }
}